﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Class_KetNoi
{
  public  class KetNoi_NguoiDung:KetNoiCoSoDuLieu
    {
        public void them_NguoiDung(string @TenDN,string @MaNV,string @MatKhau,string @MaPQ)
        {
            SqlCommand cmd = new SqlCommand("dbo.insert_NguoiDung", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@TenDN", TenDN);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaNV",Convert.ToInt32( MaNV));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MatKhau", MatKhau);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaPQ",Convert.ToInt32( MaPQ));
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
        }
        public void sua_NguoiDung(string @TenDN, string @MaNV, string @MatKhau, string @MaPQ)
        {
            SqlCommand cmd = new SqlCommand("dbo.update_NguoiDung", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@TenDN", TenDN);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaNV",MaNV);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MatKhau", MatKhau);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaPQ",Convert.ToInt32( MaPQ));
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
        }
        public void DoiMatKhau(string @TenDN, string @MatKhau)
        {
            SqlCommand cmd = new SqlCommand("dbo.DoiMatKhau", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@TenDN", TenDN);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MatKhau", MatKhau);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
        }
        public void xoa_NguoiDung(string @MaNV)
        {
            SqlCommand cmd = new SqlCommand("dbo.delete_NguoiDung", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaNV", MaNV);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();
        }
        public DataTable Load_NguoiDung()
        {
            DataTable dt = new DataTable();
            SqlCommand cmd = new SqlCommand("Load_tbl_NguoiDung",cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            return dt;
        }

    }
}
